package com.gxa.modules.app.outpatient.hscheck.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gxa.common.utils.DateUtils;
import com.gxa.common.utils.Result;
import com.gxa.modules.app.hospitalization.persional.service.PatientService;
import com.gxa.modules.model.entity.book.BookHsCheck;
import com.gxa.modules.model.entity.book.BookHsTimeNum;
import com.gxa.modules.model.entity.fee.Patient;
import com.gxa.modules.model.vo.DayAndWeekDayVO;
import com.gxa.modules.pc.order.mapper.BookHsTimeNumMapper;
import com.gxa.modules.pc.order.service.BookHsCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: zhuiyi
 * @CreatTime: 2022/11/18 9:36
 **/
@RestController
@Api(tags = "APP端--门诊服务--核酸检测")
public class AppHsCheckController {

    @Autowired
    private PatientService patientService;

    @Autowired
    private BookHsCheckService bookHsCheckService;



    @ApiOperation("根据用户id获取用户信息")
    @GetMapping("/getbyUserId/{userId}")
    public Result getbyUserId(@ApiParam(value = "当前登录用户的id") @PathVariable("userId") Integer userId){
        List<Patient> query = patientService.query(userId);
        return new Result().ok(query);
    }
    @ApiOperation("根据id获取核酸详情信息")
    @GetMapping("/heDetail/{id}")
    public Result getbyUserd(@PathVariable("id") Integer id){

        return new Result().ok(bookHsCheckService.getById(id));
    }

    @ApiOperation("获取从今天开始的7天内的日期以及星期数")
    @GetMapping("/hs/week7")
    public Result getweek7(){
        Map<String,Object> week7 = bookHsCheckService.getWeek7plus();
        return new Result().ok(week7);
    }

    @ApiOperation("时间点及剩余预约数")
    @GetMapping("/hs/timeAndNum")
    public Result timeAndNum(@ApiParam(value = "日期-例如2022-11-21") @RequestParam(value = "day") String day){
        Map<String, Object> timeAndNum = bookHsCheckService.getTimeAndNum(day);

        return new Result().ok(timeAndNum);
    }

    @ApiOperation("确认预约信息")
    @GetMapping("/hs/detail")
    public Result comfim(@ApiParam(value = "用户id 例如2") @RequestParam(value = "id") Integer id,@ApiParam(value = "时间点例如9:30") @RequestParam(value = "time") String time){
        Map<String, Object> detail = bookHsCheckService.getDetail(id,time);

        return new Result().ok(detail);
    }
    @ApiOperation("查询预约信息")
    @GetMapping("/hs/getdetail")
    public Result getDeatil(@ApiParam(value = "用户id 例如2") @RequestParam(value = "id") Integer id){
        List<BookHsCheck> detail = bookHsCheckService.getDetailbyId(id);

        return new Result().ok(detail);
    }

}
